class FiltersController < ApplicationController
  before_filter :login_required

  # GET /filters
  # GET /filters.xml
  def index
    @filters = Filter.find(:all)

    respond_to do |format|
      format.html # index.rhtml
      format.xml  { render :xml => @filters.to_xml }
    end
  end

  # GET /filters/1
  # GET /filters/1.xml
  def show
    @filter = Filter.find(params[:id])

    respond_to do |format|
      format.html # show.rhtml
      format.xml  { render :xml => @filter.to_xml }
    end
  end

  # GET /filters/new
  def new
    @filter = Filter.new
  end

  # GET /filters/1;edit
  def edit
    @filter = Filter.find(params[:id])
  end

  # POST /filters
  # POST /filters.xml
  def create
    @filter = Filter.new(params[:filter])

    respond_to do |format|
      if @filter.save
        flash[:notice] = 'Filter was successfully created.'
        format.html { redirect_to filter_url(@filter) }
        format.xml  { head :created, :location => filter_url(@filter) }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @filter.errors.to_xml }
      end
    end
  end

  # PUT /filters/1
  # PUT /filters/1.xml
  def update
    @filter = Filter.find(params[:id])

    respond_to do |format|
      if @filter.update_attributes(params[:filter])
        flash[:notice] = 'Filter was successfully updated.'
        format.html { redirect_to filter_url(@filter) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @filter.errors.to_xml }
      end
    end
  end

  # DELETE /filters/1
  # DELETE /filters/1.xml
  def destroy
    @filter = Filter.find(params[:id])
    @filter.destroy

    respond_to do |format|
      format.html { redirect_to filters_url }
      format.xml  { head :ok }
    end
  end
end
